/*
 * Copyright 2011 derek.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.aocore.item;

/**
 *
 * @author derek
 */
public enum ItemFlags
{

    None(0),
    Equipped(10),
    // UNKNOWN(2),
    // UNKNOWN(4),
    InSocket(8),
    /// <summary>
    /// Not undentified, really... also set for items that cannot be identified.
    /// </summary>
    Identified(0x10),
    /// <summary>
    /// Has to do with aura / state change !?
    /// </summary>
    x20(0x20),
    SwitchedIn(0x40),
    SwitchedOut(0x80),
    Broken(0x100),
    // UNKNOWN(0x200),
    /// <summary>
    /// Sometimes on Mana, Healing and Rejuvenation potions and runes... use is unknown.
    /// </summary>
    Duplicate(0x400),
    Socketed(0x800),
    /// <summary>
    /// Set on items equipped by Valkyrie...
    /// </summary>
    OnPet(0x1000),
    /// <summary>
    /// Set on AddToShop (but not for items I sold), on items equipped by Valkyrie.
    /// Also set on AddToGround and sometimes(?) on quest items... Special Interact ? Is New ?
    /// </summary>
    x2000(0x2000),
    NotInSocket(0x4000), // Illegal Equip ?
    // UNKNOWN(0x8000),
    /// <summary>
    /// Is a player's ear. Ear packets have a different structure...
    /// </summary>
    Ear(0x10000),
    /// <summary>
    /// Item a character started with (meaning the item worthless to resell.)
    /// </summary>
    StartItem(0x20000),
    //UNKNOWN(0x40000),
    //UNKNOWN(0x80000),
    //UNKNOWN(0x100000),
    /// <summary>
    /// Item that doesn't have an ILevel or stats.
    /// </summary>
    Compact(0x200000),
    Ethereal(0x400000),
    /// <summary>
    /// Meaning is unknown...
    /// </summary>
    Any(0x800000),
    Personalized(0x1000000),
    /// <summary>
    /// Item a town folk is offering for gambling (same purpose as Compact: no ILevel + extra info.)
    /// </summary>
    Gamble(0x2000000),
    Runeword(0x4000000),
    /// <summary>
    /// Induce State Change !?
    /// </summary>
    x8000000(0x8000000);
    //UNKNOWN(0x10000000),
    //UNKNOWN(0x20000000),
    //UNKNOWN(0x40000000),
    //UNKNOWN(0x80000000)

    private final int id;

    private ItemFlags(int id)
    {
        this.id = id;
    }

    public int getId()
    {
        return id;
    }

    public static ItemFlags valueOf(int id) throws IllegalArgumentException
    {
        for (ItemFlags itemFlags : values())
        {
            if (itemFlags.getId() == id)
            {
                return itemFlags;
            }
        }

        throw new IllegalArgumentException(id + " is not a valid ItemFlags");
    }
}
